import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
// import store from "./store";
import { store } from "./store";

/** 引入 ElementPlus */
import ElementPlus from "element-plus";
import "element-plus/lib/theme-chalk/index.css";

import "meng-ui-vue/lib/theme-chalk/mx-icon.css"

/** 引入项目全局样式 */
import "@/assets/style/index.scss";

import mitt from "mitt";

// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"

import { getDicts } from "@/api/system/dict/data";
import { parseTime, handleTree, resetForm, selectDictLabel} from "@/utils/mx"

/** 纯前端项目，线上环境使用mockjs 拦截ajax请求*/
if (process.env.NODE_ENV === "production") {
  const { mockXHR } = require("../mock");
  mockXHR();
}

const app = createApp(App);
app.config.globalProperties.mittBus = mitt();
app.config.globalProperties.getDicts = getDicts;
app.config.globalProperties.parseTime = parseTime;
app.config.globalProperties.handleTree = handleTree;
app.config.globalProperties.resetForm = resetForm;
app.config.globalProperties.selectDictLabel = selectDictLabel

app.config.globalProperties.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success" });
}
// 全局组件挂载
app.component('RightToolbar', RightToolbar)

app.use(ElementPlus).use(store).use(router).mount("#app");
